package org.wattdepot.simulation.oahugrid.main.realtime;

import it.sauronsoftware.cron4j.Scheduler;

/**
 * The main program for the real-time version of the Oahu grid simulation.
 * 
 * @author Philip Johnson
 */
public class RealtimeSimulation {

  /**
   * The main for the real time simulation. 
   * @param args Ignored.
   * @throws Exception If problems occur.
   */
  public static void main(String[] args) throws Exception {
    String schedule = "*/15 * * * *";
    Scheduler s = new Scheduler();
    s.schedule(schedule, new RealtimeSimulationTask());
    try {
      s.start();
      System.out.println("Oahu grid simulation is now running. Press return to stop server.");
      while (System.in.available() == 0) {
        Thread.sleep(2000);
      }
      System.out.println("Stopping simulation.");
      s.stop();
    }
    catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
}
